derive-ex
Improved version of the macro to implement the traits defined in the standard library.
Documentation
See #[derive_ex]
documentation for details.
Differences from standard derive macros
- A trait bound that is automatically generated is smarter.
- You can specify trait bound manually.
- You can specify default values for each field.
- You can specify comparison method for each field.
- You can specify ignored field with the derivation of
Debug
. - Support derive
Clone::clone_from
. - Support derive operators. (
Add
,AddAssign
,Not
,Deref
, etc.)
Supported traits
Copy
Clone
Debug
Default
Ord
,PartialOrd
,Eq
,PartialEq
,Hash
- operators
- Add-like (
Add
,Sub
,Mul
,Shl
, etc.) - AddAssign-like (
AddAssign
,SubAssign
,MulAssign
,ShlAssign
, etc.) - Not-like (
Not
,Neg
) Deref
,DerefMut
- Add-like (
Unsupported traits
The following traits are not supported as more suitable crates exist.
trait | crate |
---|---|
Display , FromStr |
parse-display |
Error |
thiserror |
Install
Add this to your Cargo.toml:
[]
= "0.1.7"
Example
use derive_ex;
assert_eq!;
assert_eq!;
assert_eq!;
License
This project is dual licensed under Apache-2.0/MIT. See the two LICENSE-* files for details.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.